const recommend = require('../recommend/index')
const recommendModule = require('../modules/recommend/focusDetail')

async function detail(userId) {
  const data = (await recommendModule.getFocus({})).map(item => {
    return {
      userId: item.userId,
      goodsId: item.detailId
    }
  })

  const server = new recommend.RecommendGoodsService(data, userId, 10)
  return server.start()
}

async function user(userId) {
  const data = (await recommendModule.getFocus({})).map(item => {
    return {
      userId: item.userId,
      goodsId: item.detailId
    }
  })

  const server = new recommend.RecommendUserService(data, userId, 10)
  return server.start()
}

module.exports = {
  detail,
  user
}